﻿using FireStarter.CodeGeneration.Generator;
using FireStarter.CodeGeneration.Parser;
using FireStarterModeller.BO;
using Habanero.BO.ClassDefinition;
using Habanero.BO.Loaders;

namespace FireStarterModeller.Logic
{
    public class DMToClassDefConverter
    {
        public ClassDefCol Convert(DMSolution solution)
        {
            DMToClassDefsXmlConverter toClassDefsXmlConverter = new DMToClassDefsXmlConverter();
            string xmlForSolution = toClassDefsXmlConverter.ConvertToXml(solution);
            XmlClassDefsLoader loader = new XmlClassDefsLoader(xmlForSolution, new DtdLoader());
            return loader.LoadClassDefs();
        }

        public UIDef Convert(UIView view)
        {
            DMToClassDefsXmlConverter toClassDefsXmlConverter = new DMToClassDefsXmlConverter();
            string xmlForView = toClassDefsXmlConverter.ConvertToXml(view);
            XmlUILoader loader = new XmlUILoader();
            return loader.LoadUIDef(xmlForView);
        }
    }
}